package com.hzit.mmcb.core.controller.admin;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.hzit.common.result.R;
import com.hzit.mmcb.core.enums.LendStatusEnum;
import com.hzit.mmcb.core.pojo.entity.Borrower;
import com.hzit.mmcb.core.pojo.entity.Lend;
import com.hzit.mmcb.core.service.BorrowerService;
import com.hzit.mmcb.core.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author ljh
 * @since 2024-08-27
 */
@RestController
@RequestMapping("/admin/core/lend")
@Api(tags = "标的管理")
public class AdminLendController {
    @Autowired
    private LendService lendService;


    /**
     * 查询标的列表
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询标的列表")
    private R list(){
        List<Lend> list=lendService.selectList();

        return R.ok().data("list",list);
    }

    /**
     *查询标的的信息信息
     * @param id 标的的信息
     * @return
     */
    @GetMapping("/show/{id}")
    @ApiOperation("查询标的详细信息")
    private R show(@PathVariable @ApiParam("标的id") Long id){
        Map<String,Object> lendDetail=lendService.getLendDetail(id);
        return R.ok().data("lendDetail",lendDetail);
    }

    /**
     * 放款
     */

    @GetMapping("/makeLoan/{id}")
    public R makloan(@PathVariable Long id){
        lendService.makeLoan(id);
        return R.ok();
    }

}

